if exists (select 1 from sysobjects where name = 'set_options' and type = 'P')
begin
   drop procedure set_options
   print 'Procedure: set_options deleted ...'
end
go
create procedure set_options(
  @typin             varchar(30)   = 'Arbeitszeitprotag',
  @wertin            int           = 1,
  @zahlwertin        decimal(15,2) = 8,
  @textwert          varchar(255)  = 'Stunden pro Tag'
)
as
begin
  set nocount on
  
  if exists (select 1 from Options where typ = @typin and wert = @wertin)
  begin
   delete from Options where typ = @typin and wert = @wertin
  end
  
  insert into Options (typ,wert,zahlwert,textwert) values (@typin, @wertin, @zahlwertin, @textwert)
  
end

go
print 'Procedure: set_options done ...'
go
grant exec on set_options to prsadmins with grant option
go
grant exec on set_options to prsusers
go

